﻿<controls:ChildWindow
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
           xmlns:local="clr-namespace:Candy"
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
           mc:Ignorable="d" x:Class="Candy.LoginWindow" 
           Title="LoginWindow" HasCloseButton="False"
    BorderBrush="{x:Null}"
    Style="{StaticResource ChildWindowStyleChromeless}" 
  OverlayOpacity="0" DataContext="{Binding Source={StaticResource Locator}, Path=Login}" >
    <Border Height="220" Margin="0" Width="440" BorderThickness="1" BorderBrush="{StaticResource Accent}" Background="{StaticResource ControlBackgroundDark}" >
        <Grid x:Name="LayoutRoot" ShowGridLines="False">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="200"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="70"/>
                <RowDefinition Height="Auto" MinHeight="0"/>
                <RowDefinition Height="Auto" MinHeight="0"/>
                <RowDefinition Height="Auto" MinHeight="0"/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <HyperlinkButton Content="Register" Command="{Binding Register}" HorizontalAlignment="Left" Margin="0,10,0,0" VerticalAlignment="Top" Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2" TabIndex="4" />
            <TextBlock VerticalAlignment="Center" Grid.Column="1" Grid.Row="2" ><Run Text="Use"/><Run Text="r"/></TextBlock>
            <TextBox  x:Name="TxbxUser" VerticalAlignment="Center" Margin="4,2,2,2" Grid.Column="2" Grid.Row="2" DataContext="{Binding}" Text="{Binding UserName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="16" TabIndex="1" />
            <TextBlock Text="Password"  VerticalAlignment="Center" Grid.Column="1" Grid.Row="3"   Margin="0,0,8,0"/>
            <PasswordBox KeyUp="OnKeyUp"  x:Name="passwordBox" VerticalAlignment="Center" Margin="4,7,2,2" Grid.Column="2" Grid.Row="3" Password="{Binding Password}" FontSize="16"  TabIndex="2" />
            <Button x:Name="BtnLogin" Content="Login" MinWidth="80" VerticalAlignment="Top" Margin="2,9,2,2" HorizontalAlignment="Right" Grid.Column="2" Grid.Row="4" Command="{Binding Login}" TabIndex="3">
            </Button>
            <TextBlock Height="Auto" Margin="10,76.8,10,0" Foreground="#08FFFFFF" Text="CANDY" TextWrapping="Wrap" Grid.ColumnSpan="4" FontSize="120" FontFamily="Verdana" Grid.Row="3" TextAlignment="Center" VerticalAlignment="Top" Grid.RowSpan="5" Visibility="Collapsed"/>
            <StackPanel Grid.ColumnSpan="4" Margin="0" Orientation="Vertical">
                <ProgressBar IsIndeterminate="True" Visibility="{Binding IsBusy, Converter={StaticResource VisibilityConverter}}" BorderThickness="0"/>
                <Border BorderThickness="0" Margin="0" VerticalAlignment="Top" Background="{StaticResource ValidationSummaryBrush1}" Height="25" Visibility="{Binding LoginFailed, Converter={StaticResource VisibilityConverter}}">
                    <TextBlock HorizontalAlignment="Left" Margin="8,0,0,0" TextWrapping="NoWrap" Text="Login failed" VerticalAlignment="Center"/>
                </Border>

            </StackPanel>

        </Grid>

    </Border>
</controls:ChildWindow>